﻿Imports System.Data.OleDb
Public Class Glossary
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btn_wordSearch_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_wordSearch.Click
        lbl_msgbox.Visible = True
        If tb_Word.Text = "" Then
            lbl_msgbox.Text = "Please enter a word to search"
        Else
            Panel2.Visible = True
            Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionStringList").ConnectionString)
            Dim getWord As String = "SELECT Word,Meaning from Glossary WHERE Word = @f1"
            Dim getWordCmd As OleDbCommand = New OleDbCommand(getWord, oleDbConn)
            oleDbConn.Open()
            getWordCmd.CommandType = CommandType.Text
            getWordCmd.Parameters.AddWithValue("@f1", UCase(tb_Word.Text))
            Dim dataReader = getWordCmd.ExecuteReader()
            If dataReader.HasRows Then
                lbl_msgbox.Text = "Found it!!!"
                dataReader.Read()
                lbl_word.Text = dataReader.GetString(0)
                lbl_meaning.Text = dataReader.GetString(1)
            Else
                Panel2.Visible = False
                lbl_word.Text = ""
                lbl_meaning.Text = ""
                lbl_msgbox.Text = "Sorry!! Could not find the word.."
            End If
            oleDbConn.Close()
        End If

    End Sub
End Class